package com.patui.Ui;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class HomeListAdapter extends BaseAdapter{
	public final static String TAG="@___Patui.ActicleListAdapter";
	private Context myctx;	
	public List<HomeItemInfo> Allitems;
	
	public HomeListAdapter(Context context)
	{
		myctx=context;
		Allitems=new ArrayList<HomeItemInfo>();
	}
	
    public void clear()
    {
	   Allitems.clear();
	   notifyDataSetChanged();
    }
    public void add(HomeItemInfo item)
     {
	   //MyLog.out("in add");
    	Allitems.add(item);
    	//Log.v(TAG,"WeiboInfo create."+Allitems.size());
    }
    public void remove(HomeItemInfo item)
     {
    	Allitems.remove(item);
     }
	   
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return Allitems.size();
	}

	@Override
	public HomeItemInfo getItem(int position) {
		// TODO Auto-generated method stub
		return Allitems.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		HomeItemLayout curActicleItem=(HomeItemLayout) convertView;
		if(curActicleItem==null)
		{
			curActicleItem=new HomeItemLayout(myctx);
		}
		curActicleItem.initItem(getItem(position));
		return curActicleItem;
	}

}
